forked from DiviProject/Divi
-
Notifications
You must be signed in to change notification settings - Fork 3
Custom reward addresses for masternodes #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
domob1812
wants to merge
8
commits into
DiviProject:Development
Choose a base branch
from
domob1812:custom-reward-address
base: Development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Custom reward addresses for masternodes #83
domob1812
wants to merge
8
commits into
DiviProject:Development
from
domob1812:custom-reward-address
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f207367
to
919895e
Compare
641be27
to
cad445b
Compare
f4babcd
to
551e72b
Compare
ea6a3b5
to
b2d4e5c
Compare
b2d4e5c
to
5a3311b
Compare
5910359
to
511505f
Compare
c400b74
to
774b715
Compare
58c0cd9
to
e059323
Compare
a157b4a
to
d0fff31
Compare
68a38ef
to
4e31101
Compare
84b987a
to
2582ecf
Compare
bebd6ba
to
c683b9d
Compare
c683b9d
to
29a76bc
Compare
This adds a new field, CScript rewardScript, to the masternode data structures. For now, we just add it, return it from the RPCs, and set it to the script corresponding to the collateral pubkey on creation. We also serialise the new field as part of CMasternode, which is used e.g. in the on-disk cache, but not the wire protocol (where CMasternodeBroadcast is used instead). Thus this change invalidates the mncache format, but has no other effects on compatibility. In the future, we will implement a protocol upgrade and also network fork that will use this new field so masternodes can specify an arbitrary script to which they want to receive their payments, rather than being paid always to the collateral address.
Define a new wire protocol version, and for peers that match the version, send the reward script as explicit part of the masternode broadcast messages. Also, if the reward script is not the default value, include it in the signature message of the broadcast (so that the field is authenticated by the collateral signature). Until the protocol version is bumped on the network (which is not yet the case with this commit), masternodes with non-default reward script will not be accepted as valid.
Instead of using the collateral pubkey, pay to the declared reward script of masternodes (and use that to check payments).
This extends the setupmasternode RPC method so that it allows setting a non-default reward address. The reward address is an optional sixth argument following the ip_address.
Use a custom reward address for one of the two masternodes in the mnoperation.py regtest, verifying that this works. For the test, we activate the new protocol version on regtest without any forking logic.
Custom reward addresses are one of the core features needed for proper masternode vaults. With them implemented now, we can update the mnvaults.py test (resolving two FIXME's in there) to actually make use of an explicit reward address so that the masternode rewards are received and not lost (as we want them to be in practice).
This defines a new time-activated "fork", Fork::CustomRewardAddresses. For now, it is scheduled at timestamp 2000000000; that will be set to the actual activation time once it is determined. When this fork becomes active (i.e. the current best block's timestamp goes beyond the activation time), we require peers to use the new protocol version that supports custom reward addresses. The fork has no other (in particular, no consensus-level) consequences.
This adds a new regtest, custom_address_update.py. The test runs two masternodes, where we explicitly set the protocol version of one of the nodes to the "old" version not supporting custom reward scripts for masternodes. With this test, we ensure that all the masternode networking works fine between "old" and "new" nodes before the update is activated, at least as closely as we can without running a real old node.
29a76bc
to
d9ee191
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, masternode rewards are paid to the address that holds the collateral. In some situations, this is restrictive, and it would be useful to give masternode owners a choice about where the reward should be paid to (for instance, this will allow easier setup of masternode vaults for improved security).
This set of changes implements a protocol upgrade, which then allows masternodes to (optinally) configure an arbitrary script to which rewards should be paid. Until the upgrade and until a particular masternode owner decides to explicitly opt into this feature, rewards will continue to be paid to the default script (matching the collateral address).
The protocol update itself will be activated at a hard-coded activation time using the fork activation framework from staking vaults. For now, the activation time is set to 2'000'000'000 (i.e. "far away") and will need to be adjusted once we are ready to schedule the fork.
This is #44 rebased and reopened to some changes done to the git branches.